package deom1;
class Student{
    public String name;
    public int age;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}
public class Test1 {







    public static void main6(String[] args) {
        int[] arr = {1,2,3,4,5};

        try{
            System.out.println(arr[10]);
        } catch (ArrayIndexOutOfBoundsException e) {
        } finally {
            System.out.println("finally 代码一定会执行！！！");
        }
    }




















    public static void fun(int[] arr){
        if(arr == null) {
            //该异常为编译时异常
            throw new NullPointerException("为空指针，不能用来引用");
        }
    }

    public static void main4(String[] args) {
        fun(null);
    }

    //报出我们抛出的异常
    //Exception in thread "main" java.lang.NullPointerException: 为空指针，不能用来引用









    public static void main5(String[] args) throws CloneNotSupportedException {
        Student student = new Student();
        Student student1 = (Student) student.clone();

        //报出下列异常
        //java: 未报告的异常错误java.lang.CloneNotSupportedException; 必须对其进行捕获或声明以便抛出
    }
    public static void main3(String[] args) {
        int[] arr = new int[5];
        System.out.println(arr[10]);

        //报出下列异常
        //Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 10 out of bounds for length 5
    }
    public static void main2(String[] args) {
        String str = null;
        System.out.println(str.length());

        //报出下列异常
        //Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.length()" because "str" is null
    }
    public static void main1(String[] args) {
        int tem = 10 / 0;
        System.out.println(tem);

        //报出下列异常
        //Exception in thread "main" java.lang.ArithmeticException: / by zero
    }
}
